axios.defaults.baseURL ="http://api-breakingnews-web.itheima.net"


axios.interceptors.request.use(function (confing) {
    if (confing.url.indexOf('/my') !== -1) {
        confing.headers.Authorization = localStorage.getItem('token')
    }
    return confing;
}, function (error) {
    return Promise.reject(error)
})

axios.interceptors.response.use(function (response) {
    if (response.data.message === "身份认证失败！") {
        location.href = "/login.html"
        localStorage.removeItem('token')
    }
    return response
}, function (error) {
    return Promise.reject(error)
})